import request from '@/utils/request'

// 创建试题
export function createdQuestion(data) {
  return request({
    url: '/admin-api/questions',
    method: 'post',
    data
  })
}

// 编辑试题
export function updateQuestion(id, data) {
  return request({
    url: '/admin-api/questions/' + id,
    method: 'post',
    data
  })
}

// 删除试题
export function removeQuestion(id, data) {
  return request({
    url: '/admin-api/questions/' + id,
    method: 'post',
    data
  })
}

// 试题列表
export function getQuestionData(data) {
  return request({
    url: '/admin-api/questions',
    method: 'get',
    params: data
  })
}

// 试题详情
export function getQuestionDetail(id) {
  return request({
    url: '/admin-api/questions/' + id,
    method: 'get'
  })
}

// 上传试题音频文件
export function uploadAudioFile(data) {
  return request({
    url: '/admin-api/questions/audio',
    method: 'post',
    data
  })
}

// 上传试题图片
export function uploadImageFile(data) {
  return request({
    url: '/admin-api/questions/image',
    method: 'post',
    data
  })
}

// 上传图片到oss
export function uploadImageToOss(url, data) {
  return request({
    url: url,
    method: 'post',
    data
  })
}

// 上传音频文件到oss
export function uploadAudioToOss(url, data) {
  return request({
    url: url,
    method: 'post',
    // contentType: 'multipart/form-data',
    data
  })
}

// 获取试题标签
export function getPaperQuestionTags(id) {
  return request({
    url: 'admin-api/questions/labels/' + id,
    method: 'get'
  })
}

// 更新试题标签
export function updatePaperQuestionTags(id, data) {
  return request({
    url: 'admin-api/questions/labels/' + id,
    method: 'post',
    data
  })
}
